package com.project_test.kun.travelling_1st.SplashPage;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.project_test.kun.travelling_1st.R;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class Splash_Pager_Fragment extends Fragment {
    private Splash_Pager_page1_Fragment mSplash_pager_page1_fragment;
    private Splash_Pager_page2_Fragment mSplash_pager_page2_fragment;
    private Splash_Pager_page3_Fragment mSplash_pager_page3_fragment;
    private Splash_Pager_page4_Fragment mSplash_pager_page4_fragment;
    private ViewPager mViewPager;
    private List<Fragment> Fragments;
    private FragmentPagerAdapter mAdapter;

    public Splash_Pager_Fragment() {
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mSplash_pager_page1_fragment=new Splash_Pager_page1_Fragment();
        mSplash_pager_page2_fragment=new Splash_Pager_page2_Fragment();
        mSplash_pager_page3_fragment=new Splash_Pager_page3_Fragment();
        mSplash_pager_page4_fragment=new Splash_Pager_page4_Fragment();
        Fragments=new ArrayList<>();
        Fragments.add(mSplash_pager_page1_fragment);
        Fragments.add(mSplash_pager_page2_fragment);
        Fragments.add(mSplash_pager_page3_fragment);
        Fragments.add(mSplash_pager_page4_fragment);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                  Bundle savedInstanceState) {
        View ret=inflater.inflate(R.layout.fragment_splash__pager_, container, false);
        mViewPager= (ViewPager) ret.findViewById(R.id.splash_pager);
        mAdapter=new FragmentPagerAdapter(getChildFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
               return Fragments.get(position);
            }

            @Override
            public int getCount() {

                return Fragments.size();
            }
        };
        mViewPager.setAdapter(mAdapter);
        return ret;

    }

}
